package com.amrit.collection;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.LinkedList;
import java.util.SortedSet;
import java.util.TreeSet;

import com.amrit.threads.MyThread;

public class CollectionTest {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		MyThread mt = new MyThread("Demo Thread", 11);
		//HashMap
		HashMap<Object, Object> hm = new HashMap<Object, Object>();
		hm.put(new String("ABC"), "abc");
		hm.put("ABC", "def");
		hm.put(null, "Khaali");
		hm.put(null, "duplicate");
		//LinkedList
		System.out.println(hm);
		System.out.println(hm.get(null));
		LinkedList<Object> ll = new LinkedList<Object>();
		ll.add(hm);
		ll.add("String1");
		ll.add(0, "First");
		ll.add("String2");
		ll.add(0, "Second");
		ll.add("String3");
		ll.add(0, "Third");
		ll.add("String4");
		ll.add(0, "Fourth");
		ll.add(mt);
		System.out.println("Last "+ll.getLast());
		System.out.println("First "+ll.getFirst());
		System.out.println(ll);
		System.out.println(ll.getLast().getClass().getSimpleName());
		System.out.println(ll.getLast() instanceof MyThread);


		// Tree Set
		TreeSet<String> s = new TreeSet<String>();
		s.add("A");
		s.add("b");
		s.add("a");
		s.add("B");
		System.out.println("Set s is " + s);
		SortedSet<String> ss = new TreeSet<String>();
		ss.add("A");
		ss.add("a");
		ss.add("c");
		ss.add("C");
		ss.add("b");
		ss.add("B");
		// ss.add("c");
		System.out.println("Set ss is " + ss);
		System.out.println(ss.first());

		// HashSet
		HashSet<String> hs = new HashSet<String>();
		hs.add("c");
		hs.add("C");
		hs.add("A");
		hs.add("A");
		System.out.println("HashSet hs is " + hs);

		// HashTable
		Hashtable<String, Integer> ht = new Hashtable<String, Integer>();
		ht.put("D", 4);
		ht.put("A", 1);
		ht.put("B", 2);
		ht.put("C", 3);
		System.out.println(ht.size());

		String s1 = "Amrit";
		System.out.println(s1.concat("Raj2"));
		System.out.println(s1);
		StringBuffer sb = new StringBuffer("Amrit");
		System.out.println("sb is " + sb);
		sb.append(" Raj3");
		System.out.println("now sb is " + sb);



	}

}